package com.sci.controller;

import com.sci.entity.Business;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("business")
public class BusinessController {

    // 创建日志记录器
    private static final Logger logger = LoggerFactory.getLogger(BusinessController.class);

    // 注入服务端口号
    @Value("${server.port}")
    private int serverPort;

    @GetMapping("/{id}")
    public Business getBusiness(@PathVariable(value = "id") Integer id) {
        // 打印端口信息（包含请求ID）
        logger.info("实例[端口:{}] 正在处理请求 - 商户ID: {}", serverPort, id);

        Business business = new Business();
        business.setId(id);
        business.setName("阿龙");
        business.setPhoneNumber("13866666666");
        business.setAddress("南天门一号别墅");
        return business;
    }
}
